package cl.ccs.migracionbcmc.util;

import java.util.ArrayList;
import java.util.List;

public class Result {

    private ArrayList<Exception> exceptions;

    public Result() {
        super();
        setExceptions(new ArrayList<Exception>());
    }

    public void setExceptions(ArrayList<Exception> exceptions) {
        this.exceptions = exceptions;
    }

    public List<Exception> getExceptions() {
        return exceptions;
    }

    public Exception[] getAllExceptions() {
        return (Exception[])exceptions.toArray();
    }

    public boolean isSuccess() {
        return !isNotSuccess();
    }

    public boolean isNotSuccess() {
        return (null != getExceptions()) && !(getExceptions().isEmpty());
    }

    public void addException(Exception e) {
        getExceptions().add(e);
    }

    public void addResultExceptions(Result r) {
        if (r != this) {
            for (int index = 0; index < r.getExceptions().size(); ++index) {
                this.addException(r.getExceptions().get(index));
            }
        } else {
            System.err.println("Is unncessary duplicate exceptions infinitely ...");
        }
    }

}
